package com.cvit.utils;

import com.cvit.model.Student;


public class LengthCheck {
	
	public boolean number(String num) {
        String reg = "^[0-9]{0,5}$";
        if (!num.matches(reg)) {
            return false;
        }
        return true;
 	}
	
	//判断是否为纯数字  判断长度
	public int StringLength(Student student){
		if(student.getAdjustType()!=null)
			if(number(student.getAdjustType().toString())==false)
				return 2;
		if(student.getGender()!=null)
			if(number(student.getGender().toString())==false)
				return 2;
		if(student.getExamineeType()!=null)
			if(number(student.getExamineeType().toString())==false)
				return 2;
		if(student.getDelType()!=null)
			if(number(student.getDelType().toString())==false)
				return 2;
		if(student.getApplyType()!=null)
			if(number(student.getApplyType().toString())==false)
				return 2;
		if(student.getGraduationType()!=null)
			if(number(student.getGraduationType().toString())==false)
				return 2;
		if(student.getPayType()!=null)
			if(number(student.getPayType().toString())==false)
				return 2;
		if(student.getPromiseType()!=null)
			if(number(student.getPromiseType().toString())==false)
				return 2;
		if(student.getTestType()!=null)
			if(number(student.getTestType().toString())==false)
				return 2;
		if(student.getTicketType()!=null)
			if(number(student.getTicketType().toString())==false)
				return 2;
		
		//判断string长度
		if(student.getAddressee()!="" && student.getAddressee()!=null)
			if(student.getAddressee().length() >20)
				return 1;
		if(student.getAddrTele()!="" && student.getAddrTele()!=null)
			if(student.getAddrTele().length() >20)
				return 1;
		if(student.getBirthday()!="" && student.getBirthday()!=null)
			if(student.getBirthday().length() >20)
				return 1;
		if(student.getCardId()!="" && student.getCardId()!=null)
			if(student.getCardId().length() >20)
				return 1;
		if(student.getCity()!="" && student.getCity()!=null)
			if(student.getCity().length() >10)
				return 1;
		if(student.getEamineeId()!="" && student.getEamineeId()!=null)
			if(student.getEamineeId().length() >20)
				return 1;
		if(student.getGradSchool()!="" && student.getGradSchool()!=null)
			if(student.getGradSchool().length() >125)
				return 1;
		if(student.getHeight()!="" && student.getHeight()!=null)
			if(student.getHeight().length() >10)
				return 1;
		if(student.getId()!="" && student.getId()!=null)
			if(student.getId().length() >10)
				return 1;
		if(student.getImage()!="" && student.getImage()!=null)
			if(student.getImage().length() >125)
				return 1;
		if(student.getIntheclass()!="" && student.getIntheclass()!=null)
			if(student.getIntheclass().length() >125)
				return 1;
		if(student.getLanguages()!="" && student.getLanguages()!=null)
			if(student.getLanguages().length() >10)
				return 1;
		if(student.getMailingAddress()!="" && student.getMailingAddress()!=null)
			if(student.getMailingAddress().length() >125)
				return 1;
		if(student.getName()!="" && student.getName()!=null)
			if(student.getName().length() >15)
				return 1;
		if(student.getNation()!="" && student.getNation()!=null)
			if(student.getNation().length() >10)
				return 1;
		if(student.getPassword()!="" && student.getPassword()!=null)
			if(student.getPassword().length() >20)
				return 1;
		if(student.getPostalCode()!="" && student.getPostalCode()!=null)
			if(student.getPostalCode().length() >10)
				return 1;
		if(student.getProvinces()!="" && student.getProvinces()!=null)
			if(student.getProvinces().length() >10)
				return 1;
		if(student.getRegions()!="" && student.getRegions()!=null)
			if(student.getRegions().length() >10)
				return 1;
		if(student.getTelephone()!="" && student.getTelephone()!=null)
			if(student.getTelephone().length() >20)
				return 1;
		if(student.getVolunteerFive()!="" && student.getVolunteerFive()!=null)
			if(student.getVolunteerFive().length() >125)
				return 1;
		if(student.getVolunteerFour()!="" && student.getVolunteerFour()!=null)
			if(student.getVolunteerFour().length() >125)
				return 1;
		if(student.getVolunteerThree()!="" && student.getVolunteerThree()!=null)
			if(student.getVolunteerThree().length() >125)
				return 1;
		if(student.getVolunteerTwo()!="" && student.getVolunteerTwo()!=null)
			if(student.getVolunteerTwo().length() >125)
				return 1;
		if(student.getVolunteerOne()!="" && student.getVolunteerOne()!=null)
			if(student.getVolunteerOne().length() >125)
				return 1;
		if(student.getWeigh()!="" && student.getWeigh()!=null)
			if(student.getWeigh().length() >5)
				return 1;
		return 0;
	}
}
